<template>
    <view>
        <!-- 这层标签没有也可以 -->
        <view class="uni-padding-wrap uni-common-mt">
            <view>
                <scroll-view class="scroll-view" scroll-y="true" :scroll-top="scrollTop" @scroll="scroll" @scrolltoupper="upper"
                 @scrolltolower="lower">
                    <view class="scroll-view-item top">上</view>
                    <view class="scroll-view-item center">中</view>
                    <view class="scroll-view-item bottom">下</view>
                </scroll-view>
            </view>
            <view @tap="goTop" class="uni-link uni-center uni-common-mt">
                点击这里返回顶部
            </view>
        </view>
		<!--  -->
		<view class="web_view">
			<!-- <WebView></WebView> -->
		</view>
    </view>
</template>

<script>
	import WebView from '../../components/webView/webView.vue'
    export default {
        data() {
            return {
                scrollTop: 0,
                old: {
                    scrollTop: 0,
                }
            }
        },
		components:{
			WebView
		},
		onReady() {
		console.log(this.$scope)	
		},
        methods: {
            scroll(e) {
                this.old.scrollTop = e.detail.scrollTop
            },
            goTop() {
                //这里必须将this.old.scrollTop值赋值给this.scrollTop
                // 其实将e.detail.scrollTop直接赋值给this.scrollTop也可以
                this.scrollTop = this.old.scrollTop;
                this.$nextTick(function() {
                    this.scrollTop = 0
                });
            },
            upper(){
				console.log('top')
                // 滚动到顶部/左边触发
            },
            lower(){
				console.log('bottom')
                // 滚动到底部/右边触发
            }
        }

    }
</script>

<style lang="scss">
    .scroll-view {
        // white-space: nowrap;
        height: 200px;
        width: 100%;

        .top {
            height: 200px;
            width: 100%;
            background: red;
        }

        .center {
            height: 200px;
            width: 100%;
            background: green;
        }

        .bottom {
            height: 200px;
            width: 100%;
            background: blue;
        }
    }
.web_view{
	width: 100%;
	height: 200px;
	
}
</style>